package com.mworld.galaxy.bull.entity.product;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.validation.constraints.Min;

import org.hibernate.validator.constraints.NotBlank;
import org.hibernate.validator.constraints.Range;

import com.fasterxml.jackson.annotation.JsonAutoDetect;
import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
import com.mworld.galaxy.bull.entity.StatefulIdEntity;

@Entity
@Table(name = "t_category")
@JsonAutoDetect(getterVisibility = Visibility.PUBLIC_ONLY)
public class Category extends StatefulIdEntity {
    private Shop shop;
    private String name;
    private int order;
    private int level;
    private Long level3Id;
    private Long level2Id;
    private Long level1Id;

    public Category() {
        super();
    }
    public Category(Long id) {
        super(id);
    }

    @ManyToOne
    @JoinColumn(name = "c_shop_id")
    public Shop getShop() {
        return shop;
    }

    public void setShop(Shop shop) {
        this.shop = shop;
    }

    // JSR303 BeanValidator的校验规则
    @NotBlank
    @Column(name = "c_name")
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    // JSR303 BeanValidator的校验规则
    @Min(100)
    @Column(name = "c_order")
    public int getOrder() {
        return order;
    }

    public void setOrder(int order) {
        this.order = order;
    }

    @Range(min = 1, max = 3)
    @Column(name = "c_level")
    public int getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    @Column(name = "c_level3_id")
    public Long getLevel3Id() {
        return level3Id;
    }

    public void setLevel3Id(Long level3Id) {
        this.level3Id = level3Id;
    }

    @Column(name = "c_level2_id")
    public Long getLevel2Id() {
        return level2Id;
    }

    public void setLevel2Id(Long level2Id) {
        this.level2Id = level2Id;
    }

    @Column(name = "c_level1_id")
    public Long getLevel1Id() {
        return level1Id;
    }

    public void setLevel1Id(Long level1Id) {
        this.level1Id = level1Id;
    }
}
